﻿using System;
using Bonesoft.Forms.Contabil;
using Business;
using Business.Entity.Contabil;
using Business.Entity.Contabil.Pessoa.SubClass.Usuario.ClassesRelacionadas;
using Business.Forms;
using Business.Seguranca;
using Business.Validation;
using DevExpress.XtraEditors;

namespace Bonesoft.Lists.Contabil
{
    public partial class ListTipoLancamento : ListDefault,IForm
    {
        public ListTipoLancamento()
        {
            InitializeComponent();
            FormEdit = new FormTipoLancamento();
            Reload();
        }

        public object Save()
        {
            throw new NotImplementedException();
        }

        public void Update(object entity)
        {
            FormEdit.Update(entity);
        }

        public bool Delete(object entity)
        {
            FormEdit.Delete(entity);
            return false;
        }

        public object CurrentObject
        {
            get
            {
                return tipoLancamentoBindingSource.Current;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public PermissaoForm Permissao
        {
            get
            {
                return SegurancaUtils.GetPermissaoForm(Name);
            }
        }

        public EntityValidationResult Validate()
        {
            throw new NotImplementedException();
        }

        public void Reload()
        {
            tipoLancamentoBindingSource.DataSource = TipoLancamentoRepository.GetList();
        }

        public void Cancel()
        {
            throw new NotImplementedException();
        }

        public object New()
        {
            var t = (TipoLancamento) FormEdit.New();
            if (t != null)
            {
                tipoLancamentoBindingSource.Add(t);
            }
            return t;
        }

        public XtraForm Form
        {
            get
            {
                return this;
            }
        }

        public FormState FormState { get; set; }
    }
}